package com.logic.landseaserver.ws;

import java.util.HashMap;
import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.logic.common.enums.HttpCodeEnum;
import com.logic.common.exception.BusinessException;
import com.logic.common.util.CommonResult;
import com.logic.common.util.CommonResultMap;
import com.logic.landseaserver.common.exception.LandseaBusinessException;
import com.logic.landseaserver.domain.MonthCompleteWork;
import com.logic.landseaserver.domain.Monthly;
import com.logic.landseaserver.domain.ReportChronicle;
import com.logic.landseaserver.domain.ReportConstructPeople;
import com.logic.landseaserver.domain.ReportConstructPhoto;
import com.logic.landseaserver.domain.ReportConstructSchedule;
import com.logic.landseaserver.domain.ReportDesignEngineer;
import com.logic.landseaserver.domain.ReportFund;
import com.logic.landseaserver.domain.ReportMaterial;
import com.logic.landseaserver.domain.ReportPeopleNumber;
import com.logic.landseaserver.domain.WeekCompleteWork;
import com.logic.landseaserver.domain.Weekly;
import com.logic.landseaserver.persistence.read.MonthCompleteWorkReadMapper;
import com.logic.landseaserver.persistence.read.MonthlyReadMapper;
import com.logic.landseaserver.persistence.read.ReportChronicleReadMapper;
import com.logic.landseaserver.persistence.read.ReportConstructPeopleReadMapper;
import com.logic.landseaserver.persistence.read.ReportConstructPhotoReadMapper;
import com.logic.landseaserver.persistence.read.ReportConstructScheduleReadMapper;
import com.logic.landseaserver.persistence.read.ReportDesignEngineerReadMapper;
import com.logic.landseaserver.persistence.read.ReportFundReadMapper;
import com.logic.landseaserver.persistence.read.ReportMaterialReadMapper;
import com.logic.landseaserver.persistence.read.ReportPeopleNumberReadMapper;
import com.logic.landseaserver.persistence.read.WeatherReadMapper;
import com.logic.landseaserver.persistence.read.WeekCompleteWorkReadMapper;
import com.logic.landseaserver.persistence.read.WeeklyReadMapper;
import com.logic.landseaserver.persistence.write.MonthlyWriteMapper;
import com.logic.landseaserver.persistence.write.WeeklyWriteMapper;
import com.logic.landseaserver.service.IRemouldProjectReportService;
import com.logic.landseaserver.ws.dto.MonthRemouldProjectReportDTO;
import com.logic.landseaserver.ws.dto.MonthWeekDayReportDTO;
import com.logic.landseaserver.ws.dto.QueryMonthDTO;
import com.logic.landseaserver.ws.dto.QueryMonthRemouldProjectReportDTO;
import com.logic.landseaserver.ws.dto.QueryMonthWeekDayReport;
import com.logic.landseaserver.ws.dto.QueryRemouldProjectReportDTO;
import com.logic.landseaserver.ws.dto.QueryWeekDTO;
import com.logic.landseaserver.ws.dto.QueryWeekRemouldProjectReportDTO;
import com.logic.landseaserver.ws.dto.QueryYearDTO;
import com.logic.landseaserver.ws.dto.WeekRemouldProjectReportDTO;
import com.logic.landseaserver.ws.dto.WeekReportDTO;
import com.logic.landseaserver.ws.dto.YearMonthDayReportDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Path("/remuldProjectReport")
@Api(value="remuldProjectReport")
public class RemuldProjectReportRest {
    
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    
    @Autowired
    private IRemouldProjectReportService remouldProjectReportService;
    
    @Autowired
    private MonthlyReadMapper monthlyReadMapper;
    
    @Autowired
    private ReportChronicleReadMapper reportChronicleReadMapper;
    
    @Autowired
    private WeatherReadMapper weatherReadMapper;
    
    @Autowired
    private MonthCompleteWorkReadMapper monthCompleteWorkReadMapper;
    
    @Autowired
    private ReportConstructScheduleReadMapper reportConstructScheduleReadMapper;
    
    @Autowired
    private ReportMaterialReadMapper reportMaterialReadMapper;
    
    @Autowired
    private ReportFundReadMapper reportFundReadMapper;
    
    @Autowired
    private ReportDesignEngineerReadMapper reportDesignEngineerReadMapper;
    
    @Autowired
    private ReportConstructPeopleReadMapper reportConstructPeopleReadMapper;
    
    @Autowired
    private ReportConstructPhotoReadMapper reportConstructPhotoReadMapper;
    
    @Autowired
    private WeeklyReadMapper weeklyReadMapper;
    
    @Autowired
    private WeekCompleteWorkReadMapper weekCompleteWorkReadMapper;
    
    @Autowired
    private ReportPeopleNumberReadMapper reportPeopleNumberReadMapper;
    
    @Autowired
    private WeeklyWriteMapper weeklyWriteMapper;
    
    @Autowired
    private MonthlyWriteMapper monthlyWriteMapper;
    
    //显示信息
    @POST
    @Path("/weekReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "显示新增月报周报日报时头部填充信息")
    public Response reportWeekReportDTO(@ApiParam(value = "param", required = true) @QueryParam("remouldProjectId") Integer id){
        CommonResultMap map = new CommonResultMap();
        try {
            WeekReportDTO weekReportDTO = remouldProjectReportService.getWeekReportDTO(id);	
            map.setData(weekReportDTO);
            map.setResult(CommonResult.SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/creat/weekReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Create a new weekReport")
    public Response createReport(@ApiParam(value = "param", required = true) Weekly weekly) {
        CommonResultMap map = new CommonResultMap();
        try {
            Integer weeklyId = weekly.getId();
            if (weeklyId == 0)
            {
                int id = remouldProjectReportService.insertWeekly(weekly);
                HashMap<String ,Integer > resultmap = new HashMap<String ,Integer>();
                resultmap.put("id", id);
                map.setData(resultmap);
                map.setResult(CommonResult.SUCCESS, "Create success");
            }
            else{
                String status = weekly.getStatus();
                weeklyWriteMapper.updateStatusById(weeklyId,status);
                map.setResult(CommonResult.SUCCESS, "Edit success");
            }
            
        } catch (BusinessException e) {
            e.printStackTrace();
            map.setResult(e);
        }  catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/creat/weekRemouldProjectReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Create a new weekRemouldProjectReport")
    public Response createWeekRemouldProjectReport(@ApiParam(value = "param", required = true) WeekRemouldProjectReportDTO weekRemouldProjectReportDTO) {
        CommonResultMap map = new CommonResultMap();
        try {
            if (weekRemouldProjectReportDTO.getWeather()!=null)
            {
                remouldProjectReportService.insertWeather(weekRemouldProjectReportDTO.getWeather());
            }
            
            List<WeekCompleteWork> weekCompleteWork = weekRemouldProjectReportDTO.getWeekCompleteWork();
            if (weekCompleteWork != null)
            {
                for (WeekCompleteWork weekCompleteWork2 : weekCompleteWork)
                {
                    remouldProjectReportService.insertWeekCompleteWork(weekCompleteWork2);
                }
            }
           
            List<ReportMaterial> reportMaterial = weekRemouldProjectReportDTO.getReportMaterial();
            if (reportMaterial !=null)
            {
                for (ReportMaterial reportMaterial2 : reportMaterial)
                {
                    remouldProjectReportService.insertReportMaterial(reportMaterial2);
                }
            }
           
            List<ReportConstructSchedule> reportConstructSchedule = weekRemouldProjectReportDTO.getReportConstructSchedule();
            if (reportConstructSchedule != null)
            {
                for (ReportConstructSchedule reportConstructSchedule2 : reportConstructSchedule)
                {
                    remouldProjectReportService.insertReportConstructSchedule(reportConstructSchedule2);
                }
            }
           
            if (weekRemouldProjectReportDTO.getReportPeopleNumber() !=null)
            {
                remouldProjectReportService.insertReportPeopleNumber(weekRemouldProjectReportDTO.getReportPeopleNumber());
            }
            if (weekRemouldProjectReportDTO.getReportChronicle() != null)
            {
                remouldProjectReportService.insertReportChronicle(weekRemouldProjectReportDTO.getReportChronicle());
            }
            
            map.setResult(CommonResult.SUCCESS, "Create success");
        } catch (BusinessException e) {
            e.printStackTrace();
            map.setResult(e);
        }  catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/creat/monthReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Create a new monthReport")
    public Response monthReport(@ApiParam(value = "param", required = true) Monthly monthly) {
        CommonResultMap map = new CommonResultMap();
        try {
            Integer monthlyId = monthly.getId();
            if (monthlyId == 0)
            {
                int id = remouldProjectReportService.insertMonthly(monthly);
                HashMap<String ,Integer > resultmap = new HashMap<String ,Integer>();
                resultmap.put("id", id);
                map.setData(resultmap);
                map.setResult(CommonResult.SUCCESS, "Create success");
            }
            else{
                String status = monthly.getStatus();
                monthlyWriteMapper.updateStatusById(monthlyId,status);
                map.setResult(CommonResult.SUCCESS, "Edit success");
            }
        } catch (BusinessException e) {
            e.printStackTrace();
            map.setResult(e);
        }  catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/creat/monthRemouldProjectReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Create a new monthRemouldProjectReport")
    public Response createMonthRemouldProjectReport(@ApiParam(value = "param", required = true) MonthRemouldProjectReportDTO monthRemouldProjectReportDTO) {
        CommonResultMap map = new CommonResultMap();
        try {
            List<ReportChronicle> reportChronicle = monthRemouldProjectReportDTO.getReportChronicle();
            if (reportChronicle != null)
            {
                for (ReportChronicle reportChronicle2 : reportChronicle)
                {
                    remouldProjectReportService.insertReportChronicle(reportChronicle2);
                }
            }
            
            List<MonthCompleteWork> monthCompleteWork = monthRemouldProjectReportDTO.getMonthCompleteWork();
            if (monthCompleteWork != null)
            {
                for (MonthCompleteWork monthCompleteWork2 : monthCompleteWork)
                {
                    remouldProjectReportService.insertMonthCompleteWork(monthCompleteWork2);
                }
            }
           if (monthRemouldProjectReportDTO.getWeather() != null)
        {
               remouldProjectReportService.insertWeather(monthRemouldProjectReportDTO.getWeather());
        }
            
            List<ReportConstructSchedule> reportConstructSchedule = monthRemouldProjectReportDTO.getReportConstructSchedule();
            if (reportConstructSchedule != null)
            {
                for (ReportConstructSchedule reportConstructSchedule2 : reportConstructSchedule)
                {
                    remouldProjectReportService.insertReportConstructSchedule(reportConstructSchedule2);
                }
            }
            
            List<ReportMaterial> reportMaterial = monthRemouldProjectReportDTO.getReportMaterial();
            if (reportMaterial != null)
            {
                for (ReportMaterial reportMaterial2 : reportMaterial)
                {
                    remouldProjectReportService.insertReportMaterial(reportMaterial2);
                }
            }
            
            List<ReportFund> reportFund = monthRemouldProjectReportDTO.getReportFund();
            if (reportFund != null)
            {
                for (ReportFund reportFund2 : reportFund)
                {
                    remouldProjectReportService.insertReportReportFund(reportFund2); 
                }
            }
            
            List<ReportDesignEngineer> reportDesignEngineer = monthRemouldProjectReportDTO.getReportDesignEngineer();
            if(reportDesignEngineer != null){
                for (ReportDesignEngineer reportDesignEngineer2 : reportDesignEngineer)
                {
                    remouldProjectReportService.insertReportDesignEngineer(reportDesignEngineer2);
                }
            }
            
            List<ReportConstructPeople> reportConstructPeople = monthRemouldProjectReportDTO.getReportConstructPeople();
            if (reportConstructPeople != null)
            {
                for (ReportConstructPeople reportConstructPeople2 : reportConstructPeople)
                {
                    remouldProjectReportService.insertReportConstructPeople(reportConstructPeople2);
                }
            }
            
            List<ReportConstructPhoto> reportConstructPhoto = monthRemouldProjectReportDTO.getReportConstructPhoto();
            if (reportConstructPhoto != null)
            {
                for (ReportConstructPhoto reportConstructPhoto2 : reportConstructPhoto)
                {
                    remouldProjectReportService.insertReportConstructPhoto(reportConstructPhoto2);
                }
            }
            
            map.setResult(CommonResult.SUCCESS, "Create success");
        } catch (BusinessException e) {
            e.printStackTrace();
            map.setResult(e);
        }  catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    //查看
    @POST
    @Path("/query/monthReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " select monthReport by id")
    public Response monthReport(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id){
        CommonResultMap map = new CommonResultMap();
        
        try {
            Monthly monthly = monthlyReadMapper.selectByPrimaryKey(id);
            MonthRemouldProjectReportDTO dto = new MonthRemouldProjectReportDTO();
            dto.setWeather(weatherReadMapper.selectByMonthlyId(id));
            List<ReportChronicle> reportChronicle = reportChronicleReadMapper.selectByMonthlyId(id+"");
            dto.setReportChronicle(reportChronicle);
            List<MonthCompleteWork> monthCompleteWork = monthCompleteWorkReadMapper.selectByMonthlyId(id);
            dto.setMonthCompleteWork(monthCompleteWork);
            List<ReportConstructSchedule> reportConstructSchedule = reportConstructScheduleReadMapper.selectByMonthlyId(id);
            dto.setReportConstructSchedule(reportConstructSchedule);
            List<ReportMaterial> reportMaterial = reportMaterialReadMapper.selectByMonthlyId(id+"");
            dto.setReportMaterial(reportMaterial);
            List<ReportFund> reportFund = reportFundReadMapper.selectByMonthlyId(id);
            dto.setReportFund(reportFund);
            List<ReportDesignEngineer> reportDesignEngineer = reportDesignEngineerReadMapper.selectByMonthlyId(id);
            dto.setReportDesignEngineer(reportDesignEngineer);
            List<ReportConstructPeople> reportConstructPeople = reportConstructPeopleReadMapper.selectByMonthlyId(id);
            dto.setReportConstructPeople(reportConstructPeople);
            List<ReportConstructPhoto> reportConstructPhoto = reportConstructPhotoReadMapper.selectByMonthlyId(id);
            dto.setReportConstructPhoto(reportConstructPhoto);
            QueryMonthRemouldProjectReportDTO qDto = new QueryMonthRemouldProjectReportDTO();
            qDto.setMonthly(monthly);
            qDto.setMonthRemouldProjectReportDTO(dto);
            map.setData(qDto); 
            
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/weekReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " select weekReport by id")
    public Response weekReport(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id){
        CommonResultMap map = new CommonResultMap();
        
        try {
            Weekly weekly = weeklyReadMapper.selectByPrimaryKey(id);
            WeekRemouldProjectReportDTO dto = new WeekRemouldProjectReportDTO();
            dto.setWeather(weatherReadMapper.selectByWeeklyId(id));
            ReportChronicle reportChronicle = reportChronicleReadMapper.selectByWeeklyId(id+"");
            dto.setReportChronicle(reportChronicle);
            List<WeekCompleteWork> weekCompleteWork = weekCompleteWorkReadMapper.selectByWeeklyId(id);
            dto.setWeekCompleteWork(weekCompleteWork);
            List<ReportConstructSchedule> reportConstructSchedule = reportConstructScheduleReadMapper.selectByWeeklyId(id);
            dto.setReportConstructSchedule(reportConstructSchedule);
            List<ReportMaterial> reportMaterial = reportMaterialReadMapper.selectByWeeklyId(id+"");
            dto.setReportMaterial(reportMaterial);
            ReportPeopleNumber reportPeopleNumber = reportPeopleNumberReadMapper.selectByWeeklyId(id);
            dto.setReportPeopleNumber(reportPeopleNumber);
            QueryWeekRemouldProjectReportDTO qDto = new QueryWeekRemouldProjectReportDTO();
            qDto.setWeekly(weekly);
            qDto.setWeekRemouldProjectReportDTO(dto);
            map.setData(qDto);  
            
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/dayReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " select  dayReport by id")
    public Response dayReport(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id){
        CommonResultMap map = new CommonResultMap();
        
        try {
            Weekly weekly = weeklyReadMapper.selectDay(id);
            WeekRemouldProjectReportDTO dto = new WeekRemouldProjectReportDTO();
            dto.setWeather(weatherReadMapper.selectByDayId(id));
            ReportChronicle reportChronicle = reportChronicleReadMapper.selectByDayId(id+"");
            dto.setReportChronicle(reportChronicle);
            List<WeekCompleteWork> weekCompleteWork = weekCompleteWorkReadMapper.selectByDayId(id);
            dto.setWeekCompleteWork(weekCompleteWork);
            List<ReportConstructSchedule> reportConstructSchedule = reportConstructScheduleReadMapper.selectByDayId(id);
            dto.setReportConstructSchedule(reportConstructSchedule);
            List<ReportMaterial> reportMaterial = reportMaterialReadMapper.selectByDayId(id+"");
            dto.setReportMaterial(reportMaterial);
            ReportPeopleNumber reportPeopleNumber = reportPeopleNumberReadMapper.selectByDayId(id);
            dto.setReportPeopleNumber(reportPeopleNumber);
            QueryWeekRemouldProjectReportDTO qDto = new QueryWeekRemouldProjectReportDTO();
            qDto.setWeekly(weekly);
            qDto.setWeekRemouldProjectReportDTO(dto);
            map.setData(qDto);  
            
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    //删除
    @DELETE
    @Path("/delete/monthReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "logic delete monthReport by set deleted")
    public Response monthReportDelete(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id) {
        CommonResultMap map = new CommonResultMap();
        try {
            remouldProjectReportService.deleteMonthReport(id);
            map.setResult(CommonResult.SUCCESS,"delete monthReport");
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @DELETE
    @Path("/delete/weekReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " delete weekReport  set deleted")
    public Response weekReportDelete(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id) {
        CommonResultMap map = new CommonResultMap();
        try {
            remouldProjectReportService.deleteWeekReport(id);
            map.setResult(CommonResult.SUCCESS,"delete weekReport");
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @DELETE
    @Path("/delete/dayReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " delete dayReport  set deleted")
    public Response dayReportDelete(@ApiParam(value = "param", required = true) @QueryParam("id") Integer id) {
        CommonResultMap map = new CommonResultMap();
        try {
            remouldProjectReportService.deleteDayReport(id);
            map.setResult(CommonResult.SUCCESS,"delete dayReport");
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/yearMonthDayReport")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = " yearMonthDayReport")
    public Response yearMonthDayReport(@ApiParam(value = "param", required = true)  @QueryParam("remouldProjectId") Integer id){
        CommonResultMap map = new CommonResultMap();
        try {
            YearMonthDayReportDTO report = remouldProjectReportService.getYearMonthDayReportDTO(id);
            map.setData(report);
            map.setResult(CommonResult.SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    //按照条件查询
    @POST
    @Path("/query/report/list")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "query list remouldProjects")
    public Response queryReportListDTO(@ApiParam(value = "param", required = true) QueryRemouldProjectReportDTO dto){
        CommonResultMap map = new CommonResultMap();
        List<QueryMonthWeekDayReport> remouldProjectList = null;
        try {
            remouldProjectList = remouldProjectReportService.queryListDTO(dto);
            map.setData(remouldProjectList);
            map.setResult(CommonResult.SUCCESS);
            
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/report/list/notType")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "query list remouldProjects not with type")
    public Response queryReportListDTOWithoutType(@ApiParam(value = "param", required = true) QueryRemouldProjectReportDTO dto){
        CommonResultMap map = new CommonResultMap();
        List<MonthWeekDayReportDTO> remouldProjectList = null;
        try {
            remouldProjectList = remouldProjectReportService.queryListDTOWithoutType(dto);
            map.setData(remouldProjectList);
            map.setResult(CommonResult.SUCCESS);
            
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/year")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "select year by type")
    public Response year(@ApiParam(value = "param", required = true) QueryYearDTO dto ){
        CommonResultMap map = new CommonResultMap();
        List<String> year = null;
        try {
            year = remouldProjectReportService.selectYearByType(dto);
            map.setData(year);
            map.setResult(CommonResult.SUCCESS);
           
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/month")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "select month by type and year")
    public Response year(@ApiParam(value = "param", required = true) QueryMonthDTO dto ){
        CommonResultMap map = new CommonResultMap();
        List<String> month = null;
        try {
            month = remouldProjectReportService.selectMonthByType(dto);
            map.setData(month);
            map.setResult(CommonResult.SUCCESS);
           
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    @POST
    @Path("/query/week")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "select week by type and year and month")
    public Response year(@ApiParam(value = "param", required = true) QueryWeekDTO dto ){
        CommonResultMap map = new CommonResultMap();
        List<String> week = null;
        try {
            week = remouldProjectReportService.selectWeekByType(dto);
            map.setData(week);
            map.setResult(CommonResult.SUCCESS);
           
        } catch (Exception e) {
            e.printStackTrace();
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
    
    //生成pdf
    @PUT
    @Path("/reportWeekPDF")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "生成周报pdf", position = 12)
    public Response reportWeekPDF(
            @ApiParam(value = "param", required = true) @QueryParam("id") int id) {
        CommonResultMap map = new CommonResultMap();
        String  filePath = null;
        try {
            filePath = remouldProjectReportService.getReportWeekPDF(id);
            HashMap<String, String> resultmap = new HashMap<String, String>();
            resultmap.put("filePath", filePath);
            map.setData(resultmap);
            map.setResult(CommonResult.SUCCESS);
        } catch (LandseaBusinessException e) {
            logger.error("reportWeekPDF error.", e);
            map.setResult(CommonResult.BUSINESS_EXCEPTION, e.getMessage());
        } catch (Exception e) {
            logger.error("reportWeekPDF error.", e);
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }

    @PUT
    @Path("/reportDayPDF")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "生成日报pdf", position = 12)
    public Response reportDayPDF(
            @ApiParam(value = "param", required = true) @QueryParam("id") int id) {
        CommonResultMap map = new CommonResultMap();
        String  filePath = null;
        try {
            filePath = remouldProjectReportService.getReportDayPDF(id);
            HashMap<String, String> resultmap = new HashMap<String, String>();
            resultmap.put("filePath", filePath);
            map.setData(resultmap);
            map.setResult(CommonResult.SUCCESS);
        } catch (LandseaBusinessException e) {
            logger.error("reportDayPDF error.", e);
            map.setResult(CommonResult.BUSINESS_EXCEPTION, e.getMessage());
        } catch (Exception e) {
            logger.error("reportDayPDF error.", e);
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }

    @PUT
    @Path("/reportMonthPDF")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "生成月报pdf", position = 12)
    public Response reportMonthPDF(
            @ApiParam(value = "param", required = true) @QueryParam("id") int id) {
        CommonResultMap map = new CommonResultMap();
        String  filePath = null;
        try {
            filePath = remouldProjectReportService.getReportMonthPDF(id);
            HashMap<String, String> resultmap = new HashMap<String, String>();
            resultmap.put("filePath", filePath);
            map.setData(resultmap);
            map.setResult(CommonResult.SUCCESS);
        } catch (LandseaBusinessException e) {
            logger.error("reportMonthPDF error.", e);
            map.setResult(CommonResult.BUSINESS_EXCEPTION, e.getMessage());
        } catch (Exception e) {
            logger.error("reportMonthPDF error.", e);
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }

}
